<?php
//by willson 105328468@qq.com 2014/10/11
//index page interface

class member_model extends base_model {
	public $table;

	public function __construct() {
		parent::__construct();
		$this->table = $this->tbp."member";
	}

	public function status_name($status) {
		$str = '';
		switch($status){
			case 0:$str = '冻结';break;
			case 1:$str = '正常';break;
		}
		return $str;
	}

	public function member_type($type) {
		$str = '';
		switch($type){
			case 1:$str = '普通会员';break;
			case 2:$str = '门店店员';break;
			case 3:$str = '门店店长';break;
		}
		return $str;
	}

	public function integral_name($type){
		$str = '';
		switch($type){
			case 0:$str = '商城消费';break;
			case 1:$str = '数商转入';break;
		}
		return $str;
	}

	//会员详情
	public function detail($id) {
		$where = '';
		$sql = "SELECT * FROM jf_member WHERE id='{$id}'";
		$member = $this->db->get_row($sql);
		if ($member) {
			$member->avatar = $member->avatar=='' ? '/images/default_avatar.jpg' : $member->avatar;
		}
		return $member;
	}

	//从会员id获取udid
	public function get_udid_from_member_id($member_id) {
		$sql = "SELECT udid FROM jf_member WHERE id='{$member_id}'";
		$udid = trim($this->db->get_var($sql));
		return $udid;
	}

	//从店铺id获取udid
	public function get_udid_from_shop_id($shop_id) {
		$sql = "SELECT udid FROM jf_shop s INNER JOIN ejd_member m ON s.member_id=m.id WHERE s.id='{$shop_id}'";
		$udid = trim($this->db->get_var($sql));
		return $udid;
	}

}
